/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.view;

import com.model.Pesanan;
import com.rekap.*;
import com.tools.koneksi;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import prototype.pesanan_kk;

/**
 *
 * @author Reaper
 */
public class FormKonfirmasi extends javax.swing.JFrame {

    /**
     * Creates new form FormKonfirmasi
     */
    public FormKonfirmasi() {
        initComponents();
        liat();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        labelID = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        labelnama = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        labelTelp = new javax.swing.JLabel();
        labelPaket = new javax.swing.JLabel();
        labelJumlah = new javax.swing.JLabel();
        labelHargaTotal = new javax.swing.JLabel();
        labelTanggalJadi = new javax.swing.JLabel();
        Cetak = new javax.swing.JButton();
        tanggal_field = new javax.swing.JTextField();
        harga_field = new javax.swing.JTextField();
        jumlah_field = new javax.swing.JTextField();
        paket_field = new javax.swing.JTextField();
        telp_field = new javax.swing.JTextField();
        alamat_field = new javax.swing.JTextField();
        nama_field = new javax.swing.JTextField();
        member_field = new javax.swing.JTextField();
        pesan_field = new javax.swing.JTextField();
        Cetak1 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        file = new javax.swing.JMenu();
        home = new javax.swing.JMenuItem();
        exit = new javax.swing.JMenu();
        menuEdit = new javax.swing.JMenu();
        order = new javax.swing.JMenuItem();
        lihatPesanan = new javax.swing.JMenuItem();
        paket = new javax.swing.JMenu();
        lihatDaftarPaket = new javax.swing.JMenuItem();
        tambahPaket = new javax.swing.JMenuItem();
        member = new javax.swing.JMenu();
        lihatMember = new javax.swing.JMenuItem();
        tambahMember = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Form Konfirmasi");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("PESANAN");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(231, 83, -1, -1));

        labelID.setText("ID Pesanan      :");
        getContentPane().add(labelID, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 105, -1, -1));

        jLabel2.setText("ID Member       :");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 135, -1, -1));

        labelnama.setText("Nama               :");
        getContentPane().add(labelnama, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 165, -1, -1));

        jLabel3.setText(" Alamat            :");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 195, -1, -1));

        labelTelp.setText(" No telp            :");
        getContentPane().add(labelTelp, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 225, 80, -1));

        labelPaket.setText("Paket               :");
        getContentPane().add(labelPaket, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 255, -1, -1));

        labelJumlah.setText("Jumlah             :");
        getContentPane().add(labelJumlah, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 285, -1, -1));

        labelHargaTotal.setText("Harga              :");
        getContentPane().add(labelHargaTotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 315, -1, -1));

        labelTanggalJadi.setText("Tanggal Jadi    :");
        getContentPane().add(labelTanggalJadi, new org.netbeans.lib.awtextra.AbsoluteConstraints(32, 345, -1, -1));

        Cetak.setText("cetak");
        Cetak.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CetakActionPerformed(evt);
            }
        });
        getContentPane().add(Cetak, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 150, -1, -1));

        tanggal_field.setEnabled(false);
        tanggal_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tanggal_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(tanggal_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 340, 150, -1));

        harga_field.setEnabled(false);
        harga_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                harga_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(harga_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 310, 150, -1));

        jumlah_field.setEnabled(false);
        jumlah_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jumlah_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(jumlah_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 280, 150, -1));

        paket_field.setEnabled(false);
        paket_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                paket_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(paket_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 250, 150, -1));

        telp_field.setEnabled(false);
        telp_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                telp_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(telp_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 220, 150, -1));

        alamat_field.setEnabled(false);
        alamat_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                alamat_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(alamat_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 190, 150, -1));

        nama_field.setEnabled(false);
        nama_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nama_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(nama_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 160, 150, -1));

        member_field.setEnabled(false);
        member_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                member_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(member_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 130, 150, -1));

        pesan_field.setEnabled(false);
        pesan_field.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pesan_fieldActionPerformed(evt);
            }
        });
        getContentPane().add(pesan_field, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 100, 150, -1));

        Cetak1.setText("kembali");
        Cetak1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Cetak1ActionPerformed(evt);
            }
        });
        getContentPane().add(Cetak1, new org.netbeans.lib.awtextra.AbsoluteConstraints(424, 311, -1, -1));

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/background.jpg"))); // NOI18N
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 510, 380));

        file.setText("File");

        home.setText("Home");
        home.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeActionPerformed(evt);
            }
        });
        file.add(home);

        exit.setText("Exit");
        exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitActionPerformed(evt);
            }
        });
        file.add(exit);

        jMenuBar1.add(file);

        menuEdit.setText("Pesanan");
        menuEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuEditActionPerformed(evt);
            }
        });

        order.setText("order");
        order.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                orderActionPerformed(evt);
            }
        });
        menuEdit.add(order);

        lihatPesanan.setText("lihat pesanan");
        lihatPesanan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatPesananActionPerformed(evt);
            }
        });
        menuEdit.add(lihatPesanan);

        jMenuBar1.add(menuEdit);

        paket.setText("Paket");

        lihatDaftarPaket.setText("lihat daftar Paket");
        lihatDaftarPaket.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatDaftarPaketActionPerformed(evt);
            }
        });
        paket.add(lihatDaftarPaket);

        tambahPaket.setText("tambah Paket");
        tambahPaket.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tambahPaketActionPerformed(evt);
            }
        });
        paket.add(tambahPaket);

        jMenuBar1.add(paket);

        member.setText("Member");

        lihatMember.setText("lihat Member");
        lihatMember.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatMemberActionPerformed(evt);
            }
        });
        member.add(lihatMember);

        tambahMember.setText("tambah Member");
        member.add(tambahMember);

        jMenuBar1.add(member);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void homeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeActionPerformed
        FromMenuOperator home = new FromMenuOperator();
        home.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_homeActionPerformed

    private void exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitActionPerformed
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_exitActionPerformed

    private void orderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orderActionPerformed
        FormPesanan pesan = new FormPesanan();
        pesan.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_orderActionPerformed

    private void lihatPesananActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatPesananActionPerformed
        view_pesanan viewp = new view_pesanan();
        viewp.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatPesananActionPerformed

    private void menuEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuEditActionPerformed
        FormPesanan edit = new FormPesanan();
        edit.setVisible(true);
        this.dispose();// TODO add your handling code here:
    }//GEN-LAST:event_menuEditActionPerformed

    private void lihatDaftarPaketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatDaftarPaketActionPerformed
        view_menu viewm = new view_menu();
        viewm.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatDaftarPaketActionPerformed

    private void tambahPaketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tambahPaketActionPerformed
        FormMenuTambah addMenu = new FormMenuTambah();
        addMenu.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_tambahPaketActionPerformed

    private void lihatMemberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatMemberActionPerformed
        view_member viewber = new view_member();
        viewber.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatMemberActionPerformed

    private void CetakActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CetakActionPerformed
        try {
            String kirim = "Dibuat";
            Pesanan pesan = new Pesanan();
            DataHandler dataHandler = new DataHandler();
            dataHandler.getDBConnection();
            Connection conn = dataHandler.conn;
            Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
            String query = "insert into pesanan (idpesanan, idmember, nama, alamat, notelp,paket, jumlah, hargatotal,tanggaljadi, status, pengiriman) values('"
                    + pesan.getId_pesanan() + "','" + pesan.getId_member()
                    + "','" + pesan.getNama() + "','" + pesan.getAlamat() + "','" + pesan.getTelp()
                    + "','" + pesan.getPaket() + "'," + Integer.parseInt(jumlah_field.getText()) + "," + Integer.parseInt(harga_field.getText()) + ",'"
                    + pesan.getJadi() + "','" + pesan.getStatus() + "','" + kirim + "')";
            stmt.executeUpdate(query);
            JOptionPane.showMessageDialog(null, "Pesanan berhasil disimpan");
        } // TODO add your handling code here:
        catch (SQLException ex) {
            Logger.getLogger(FormPesanan.class.getName()).log(Level.SEVERE, null, ex);
        }
//                System.out.println("\nExecuting query: " + query);

        koneksi connect = new koneksi();
        Connection kon = null;
        String reportSource = "";
        kon = connect.getDBConnection();
        reportSource = "./report/nota euy.jasper";
        Map<String, Object> params = new HashMap<String, Object>();
        try {
            JasperPrint jasperPrint = null;
//                try {
            jasperPrint = JasperFillManager.fillReport(reportSource, params, kon);
//                } catch (JRException ex) {
//                    Logger.getLogger(kertu_stok.class.getName()).log(Level.SEVERE, null, ex);
//                }
            JasperViewer.viewReport(jasperPrint, false);

        } catch (JRException ex) {
            ex.printStackTrace();

        }

        this.setExtendedState(JFrame.ICONIFIED);        // TODO add your handling code here:
    }//GEN-LAST:event_CetakActionPerformed

    private void tanggal_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tanggal_fieldActionPerformed

    }//GEN-LAST:event_tanggal_fieldActionPerformed

    private void harga_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_harga_fieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_harga_fieldActionPerformed

    private void jumlah_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jumlah_fieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jumlah_fieldActionPerformed

    private void paket_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_paket_fieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_paket_fieldActionPerformed

    private void telp_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_telp_fieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_telp_fieldActionPerformed

    private void alamat_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alamat_fieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_alamat_fieldActionPerformed

    private void nama_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nama_fieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nama_fieldActionPerformed

    private void member_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_member_fieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_member_fieldActionPerformed

    private void pesan_fieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pesan_fieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pesan_fieldActionPerformed

    private void Cetak1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Cetak1ActionPerformed
        FormPesanan form = new FormPesanan();
        form.setVisible(true);
        dispose();
    }//GEN-LAST:event_Cetak1ActionPerformed
    public void liat() {
        Pesanan pesan = new Pesanan();
        String field_pesan = pesan.getId_pesanan();
        pesan_field.setText(field_pesan);
        member_field.setText(pesan.getId_member());
        nama_field.setText(pesan.getNama());
        alamat_field.setText(pesan.getAlamat());
        telp_field.setText(pesan.getTelp());
        paket_field.setText(pesan.getPaket());
        jumlah_field.setText(String.valueOf(pesan.getJumlah()));
        harga_field.setText(String.valueOf(pesan.getTotal()));
        tanggal_field.setText(pesan.getJadi());
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FormKonfirmasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FormKonfirmasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FormKonfirmasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FormKonfirmasi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FormKonfirmasi().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Cetak;
    private javax.swing.JButton Cetak1;
    private javax.swing.JTextField alamat_field;
    private javax.swing.JMenu exit;
    private javax.swing.JMenu file;
    private javax.swing.JTextField harga_field;
    private javax.swing.JMenuItem home;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JTextField jumlah_field;
    private javax.swing.JLabel labelHargaTotal;
    private javax.swing.JLabel labelID;
    private javax.swing.JLabel labelJumlah;
    private javax.swing.JLabel labelPaket;
    private javax.swing.JLabel labelTanggalJadi;
    private javax.swing.JLabel labelTelp;
    private javax.swing.JLabel labelnama;
    private javax.swing.JMenuItem lihatDaftarPaket;
    private javax.swing.JMenuItem lihatMember;
    private javax.swing.JMenuItem lihatPesanan;
    private javax.swing.JMenu member;
    private javax.swing.JTextField member_field;
    private javax.swing.JMenu menuEdit;
    private javax.swing.JTextField nama_field;
    private javax.swing.JMenuItem order;
    private javax.swing.JMenu paket;
    private javax.swing.JTextField paket_field;
    private javax.swing.JTextField pesan_field;
    private javax.swing.JMenuItem tambahMember;
    private javax.swing.JMenuItem tambahPaket;
    private javax.swing.JTextField tanggal_field;
    private javax.swing.JTextField telp_field;
    // End of variables declaration//GEN-END:variables
}
